'MACRO TITLE: AUTO-CREATE DATA DICTIONARY
'The purpose of this macro is to create a user defined data dictionary quickly. The macro
'can be used as a template to create user-defined or business-specific data dictionaries. This macro
'can be inserted into ER/Studio's ERSBasicHandlers system (specifically in the
'"CreateDiagramHandler(CurDiagram As Object)" section of ERSBasicHandlers) and if the Create Handlers
'option is checked on in ER/Studio's Automation Interface Options, this Data Dictionary will be created
'and populated any time a user creates a new diagram.
'------------------------------------------------------------------------------------------
Sub Main()
        Dim MyDiagram As Diagram
        Dim MyModel As Model
        Dim MyDomain As Domain
        Dim MyDictionary As Dictionary
        Dim ID As Integer

        'Create a new diagram.

        Set MyDiagram = DiagramManager.ActiveDiagram

        'Get the data dictionary.

        Set MyDictionary = MyDiagram.Dictionary

        'Get the current model (in this case, the logical model).

        Set MyModel = MyDiagram.ActiveModel

        'ID domain.

        Set MyDomain = MyDictionary.Domains.Add("ID", "ID")
        MyDomain.Datatype = "BIGINT"
	    MyDomain.Identity = True
	    MyDomain.IdentitySeed = 1
	    MyDomain.IdentityIncrement = 1

		'Unique ID domain
        Set MyDomain = MyDictionary.Domains.Add("UUID", "UUID")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 36
        MyDomain.Nullable = False

        Set MyDomain = MyDictionary.Domains.Add("Hits", "Hits")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False
        MyDomain.DeclaredDefault = 0


        Set MyDomain = MyDictionary.Domains.Add("Price", "Price")
        MyDomain.Datatype = "NUMERIC"
        MyDomain.DataLength = 10
        MyDomain.DataScale = 2
        MyDomain.Nullable = False

        Set MyDomain = MyDictionary.Domains.Add("LanguageID", "Language ID")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 36
        MyDomain.Nullable = False

        Set MyDomain = MyDictionary.Domains.Add("TextID", "Text ID")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False




        Set MyDomain = MyDictionary.Domains.Add("RowVersionStamp", "Row Version Stamp")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False

        Set MyDomain = MyDictionary.Domains.Add("ReferenceID", "Reference ID")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False

        'Name domain.

        Set MyDomain = MyDictionary.Domains.Add("Name", "Name")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 60
        MyDomain.Nullable = False

        'LongName domain.

        Set MyDomain = MyDictionary.Domains.Add("LongName", "Name")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 254
        MyDomain.Nullable = False

        'Owner domain.

        Set MyDomain = MyDictionary.Domains.Add("Owner", "Owner")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 30
        MyDomain.Nullable = True

        'Description domain.

        Set MyDomain = MyDictionary.Domains.Add("Description", "Description")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 1000
        MyDomain.Nullable = True

        'Comments domain.

        Set MyDomain = MyDictionary.Domains.Add("Comments", "Comments")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 254
        MyDomain.Nullable = True

        'FilePath domain.

        Set MyDomain = MyDictionary.Domains.Add("FilePath", "File Path")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 254
        MyDomain.Nullable = True



        'URL domain.

        Set MyDomain = MyDictionary.Domains.Add("URL", "URL")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 254
        MyDomain.Nullable = True

        'Quantity domain.

        Set MyDomain = MyDictionary.Domains.Add("Quantity", "Quantity")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False

        'SequenceNbr domain.

        Set MyDomain = MyDictionary.Domains.Add("SequenceNbr", "Sequence Nbr")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False




        Set MyDomain = MyDictionary.Domains.Add("Ordering", "Ordering")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False
		MyDomain.DeclaredDefault = 1


        Set MyDomain = MyDictionary.Domains.Add("Epoch", "Epoch")
        MyDomain.Datatype = "INTEGER"
        MyDomain.Nullable = False
        MyDomain.DeclaredDefault = 1

        'Percent domain.

        Set MyDomain = MyDictionary.Domains.Add("Percent", "Percent")
        MyDomain.Datatype = "NUMERIC"
        MyDomain.DataLength = 5
        MyDomain.DataScale = 3
        MyDomain.Nullable = True

        'Is domain.

        Set MyDomain = MyDictionary.Domains.Add("Active", "Active")
        MyDomain.Datatype = "TINYINT"
        MyDomain.Nullable = False
		MyDomain.DeclaredDefault = 1


        'CreateDate.

        Set MyDomain = MyDictionary.Domains.Add("CreatedOn", "Created On")
        MyDomain.Datatype = "DATETIME"
        MyDomain.Nullable = False
        MyDomain.DeclaredDefault = "'2008-01-01 00:00:00'"

        'CreatedBy.

        Set MyDomain = MyDictionary.Domains.Add("CreatedBy", "Created By")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 30
        MyDomain.Nullable = False
        'MyDomain.DeclaredDefault = ""

        'ModifiedDate.

        Set MyDomain = MyDictionary.Domains.Add("LastUpdatedOn", "Last Updated On")
        MyDomain.Datatype = "DATETIME"
        MyDomain.Nullable = True 'False
        'MyDomain.DeclaredDefault = "'0000-00-00'"

        'ModifiedBy.

        Set MyDomain = MyDictionary.Domains.Add("LastUpdatedBy", "LastUpdated By")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 30
        MyDomain.Nullable = True 'False
        'MyDomain.DeclaredDefault = ""


        Set MyDomain = MyDictionary.Domains.Add("LastDeletedOn", "Last Deleted On")
        MyDomain.Datatype = "DATETIME"
        MyDomain.Nullable = False
        MyDomain.DeclaredDefault = ""



        Set MyDomain = MyDictionary.Domains.Add("LastDeletedBy", "LastDeleted By")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 30
        MyDomain.Nullable = False
        MyDomain.DeclaredDefault = ""

        'ModifiedDate.

        Set MyDomain = MyDictionary.Domains.Add("LastModifiedOn", "Last Modified On")
        MyDomain.Datatype = "DATETIME"
        MyDomain.Nullable = False
        MyDomain.DeclaredDefault = "'2008-01-01 00:00:00'"

        'ModifiedBy.

        Set MyDomain = MyDictionary.Domains.Add("LastModifiedBy", "LastModified By")
        MyDomain.Datatype = "VARCHAR"
        MyDomain.DataLength = 30
        MyDomain.Nullable = False
        MyDomain.DeclaredDefault = ""


        'RowTimestamp.

        Set MyDomain = MyDictionary.Domains.Add("RowTimestamp", "RowTimestamp")
        MyDomain.Datatype = "TIMESTAMP"
        MyDomain.Nullable = True


End Sub
